<template>
  <div class="hello">
    <h2>欢迎注册</h2>
    <mt-field label="手机号" placeholder="请输入手机号" v-model="phone"></mt-field>
    <mt-field label="密码" placeholder="请输入密码" type="password" v-model="password"></mt-field>
    <mt-button size="large" type="primary" @click.native="register()"> 注册</mt-button>
    <mt-button size="large" type="danger" @click.native="login()">去登录</mt-button>
  </div>
</template>

<script>
import url from "../tools/url"
import { Toast } from 'mint-ui';
export default {
  name: 'Register',
  data () {
    return {
        phone:"",
        password:""
    }
  },
  methods:{
    // 注册
     register(){
        var str =`phone=${this.phone}&password=${this.password}`;
        this.axios.post(url.REGISTER,str)
        .then(res=>{
            console.log(res);
            if(res.data.code==200){
                Toast(res.data.message);
                this.$router.push("/Login")
            }else{
                 Toast(res.data.message);
            }
        })
    },
    //  去登录

     login(){
         this.$router.push("/Login")
    }

  },
  mounted(){

  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
